﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using ZLDC.Common.Estate;
using System.Data;

namespace ZLDC.Topo.BLL.Estate
{
    public class NewsBLL
    {
        public static string p_News_List(string condition) 
        {
            DataTable dt = null;
            using (_Database db = new _Database("estate")) 
            {
                dt = ZLDC.DAL.Estate.NewsDAL.p_list_news(condition,db);
            }
            _Json json = new _Json(dt, "yyyy-MM-dd HH:mm:ss");
            
            return "{record:" + json.ToJson() + "}";

        }
        public static DataSet p_list_Details(int id)
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.NewsDAL.p_list_Details(id, db);
            }
        }
        public static string InsertNews(string condition)
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.NewsDAL.InsertNews(condition,db);
            }
        }

        public static string p_news_list_table(int page, int pagesize)
        {
            DataTable dt = null;
            int total = 0;                       int pageall = 0;                     using (_Database db = new _Database("estate")) 
            {
                dt=ZLDC.DAL.Estate.NewsDAL.p_news_list_table(page, pagesize, ref total, db);
            }

            pageall=_Utility.GetPageAll(pagesize,total);

            _Json json=new _Json (dt,"yyyy-MM-dd HH:mm:ss");

            return "{page:{currentpage:'" + page + "',pagesize:'" + pagesize + "',total:'" + total + "',pageall:'" + pageall + "'},record:" + json.ToJson() + "}";

        }

        public static string UpdateNews(int id, string condition)
        {
            using (_Database db = new _Database("estate")) 
            {
                return ZLDC.DAL.Estate.NewsDAL.UpdateNews(id,condition,db);
            }
            
        }
    }
}
